<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/extjs_all/resources/css/ext-all.css"/>
<script type="text/javascript" src="<%= request.getContextPath() %>/extjs_all/adapter/ext/ext-base.js" ></script>
<script type="text/javascript" src="<%= request.getContextPath() %>/extjs_all/ext-all.js" ></script>
<%-- <script type="text/javascript" src="<%= request.getContextPath() %>/myext/login.js" ></script> --%>
<title>登陆</title>
<script type="text/javascript">
Ext.onReady(function(){
    Ext.QuickTips.init();	//初始化Ext.QuickTips，以使得tip提示可用
    Ext.form.Field.prototype.msgTarget='side';		//提示后面显示图片标记
	var loginForm = new Ext.form.FormPanel({
		clientValidation:true,	//客户端验证
		renderTo:'loginForm',
		title:'用户登陆',
		labelWidth:50,
		height:150,
		width:350,
		frame:true,			//此窗口panel具有全部阴影
		labelSeparator:':',
		labelAlign:'right',
		bodyStyle:'padding:8px',
		items:[
				new Ext.form.TextField({
					fieldLabel:'用户名',
					name:'userinfo.loginname',
					id:'userinfo.loginname',
					inputType:'text',
					width:220,
					allowBlank:false,
					cls : "login",
					style:{
						background: '#ffffff url(imgs/user.png) no-repeat left center',
						paddingLeft: '20px' 
					}, 
					value:'shujie',
					blankText:'请输入用户名！'
					
				}),
				
				new Ext.form.TextField({
					fieldLabel:'密码',
					name:'userinfo.password',
					id:'userinfo.password',
					inputType:'password',
					width:220,
					allowBlank:false,
					style:{
						background: '#ffffff url(imgs/computer_key.png) no-repeat left center',
						paddingLeft: '20px' 
					}, 
					value:'1',
					blankText:'请输入密码！'
				}) 
		],
		buttons:[
			new Ext.Button({
				text:'登陆',
				handler:login
			}),
			new Ext.Button({
				text:'跳转',
				handler:login
			}),
			new Ext.Button({
				text:'重置',
				handler:reset
			})
		]
	 
	})
	
	function login(){
		 if (loginForm.form.isValid()) {
			 Ext.Ajax.request({
// 			 	waitTitle:'提示',
// 	 			waitMsg:'正在登录系统请稍后',
				url:'login.action',
				params:{
					'userLogin.loginname':Ext.getCmp('userinfo.loginname').getValue(),
					'userLogin.password':Ext.getCmp('userinfo.password').getValue()
				},
				//提交成功后,处理一些事务
				success : function(response){
					var value = Ext.util.JSON.decode(response.responseText);
					if(value.success == true){
						Ext.Msg.alert('提示','登录成功！');
						document.location="page/main.jsp";
// 						loginForm.getForm().getEl().dom.action= "mainpanel.action";   
// 						loginForm.getForm().getEl().dom.submit();  
					}else{
						Ext.Msg.alert('提示',value.msg);
					}
				}
			});
		}else{
			Ext.Msg.alert('提示', "验证未通过，请重新填写！");
		}
	}
	
	function reset(){
		loginForm.form.reset();
	}
});
</script>

</head>
<body>
<br/><br/><br/><br/><br/><br/><br/><br/>
<br/><br/><br/><br/><br/><br/><br/><br/>

<center><div id="loginForm" align="center"></div></center>
</body>
</html>